package com.redstar.interesting.common.exception;

import com.redstar.interesting.common.enums.EnumServerCode;

/**
 * @author lihongxing
 */
public class BaseException extends RuntimeException{
    private static final long serialVersionUID = -7320959498334150097L;

    private EnumServerCode code;

    private String desc;


    public BaseException(EnumServerCode code) {
        super();
        this.code = null != code? code:EnumServerCode.SERVER_UNKNOWN_ERROR;
        this.desc = this.code.getDesc();

    }

    public BaseException(EnumServerCode code, String desc) {
        super(desc);
        this.code = null != code? code:EnumServerCode.SERVER_UNKNOWN_ERROR;
        this.desc = (desc == null || desc.length() == 0) ? this.code.getDesc() : desc;
    }

    public EnumServerCode getCode() {
        return code;
    }

    public void setCode(EnumServerCode code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
